package com.web.controller;

import com.web.com.web.entity.Student;
import com.web.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/student")
public class StudentController {

    @Autowired
    private StudentService  studentService;

    @RequestMapping("/list")
    public List<Student> list() {
        return studentService.findAll();
    }

    @RequestMapping("/get")
    public Student get(Integer id) {
        return studentService.findById(id);
    }

    @RequestMapping("/save")
    public String save(Student student) {
        studentService.save(student);
        return "新增成功";
    }

    @RequestMapping("/update")
    public String update(Student student) {
        studentService.update(student);
        return "修改成功";
    }

    @RequestMapping("/delete")
    public String delete(Integer id) {
        studentService.delete(id);
        return "删除成功";
    }


}
